package o;

import android.app.NotificationManager;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Build;
import android.os.Build.VERSION;
import android.service.notification.StatusBarNotification;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import androidx.annotation.RequiresApi;
import com.huawei.hms.support.api.entity.pay.HwPayConstant;
import com.huawei.hwid.core.constants.HwAccountConstants;
import com.huawei.secure.android.common.intent.SafeIntent;
import java.util.LinkedHashMap;

public class dli {
    public static SharedPreferences ˊ(Context context) {
        return context.getSharedPreferences("OOBEParam", 0);
    }

    @RequiresApi(api = 21)
    public static boolean ॱ(Context context) {
        if (ˊ(context).getBoolean("setupwizardFinished", false)) {
            return false;
        }
        Logger.e("OOBE", "checkIfDataCleared:true");
        ˎ(context);
        return true;
    }

    @RequiresApi(api = 21)
    public static int ˋ(Context context) {
        if (!ॱ(context)) {
            return 0;
        }
        Logger.e("OOBE", "checkOOBEState oobe data cleared");
        return 2;
    }

    public static boolean ˏ(Context context) {
        return !ˊ(context).getBoolean("setupwizardFinished", false);
    }

    public static void ˎ(Context context) {
        ll.ˏ(context).ˋ(new Intent("com.huawei.appmarket.oobe.app.action.ACTION_OOBE_ALL_DONE"));
    }

    public static boolean ˊ(Context context, String str) {
        try {
            if (context.getPackageManager().getPackageInfo(str, 0) == null) {
                return false;
            }
            return true;
        } catch (NameNotFoundException e) {
            return false;
        }
    }

    public static boolean ॱॱ(Context context) {
        return (context.getResources().getConfiguration().screenLayout & 15) >= 3;
    }

    public static void ʻ(Context context) {
        if (context != null) {
            Logger.ˎ("OOBE", "save cota: is OpenChannel");
            ˊ(context).edit().putString("isOpenChannel", "1").putBoolean("cotaOk", true).commit();
        }
    }

    public static void ˊ(Context context, SafeIntent safeIntent) {
        if (context != null) {
            String stringExtra = safeIntent.getStringExtra("isOpenChannel");
            String stringExtra2 = safeIntent.getStringExtra("channelInfo");
            if (dof.ˋ(stringExtra) || dof.ˋ(stringExtra2)) {
                Logger.ˎ("OOBE", "cota not valid");
                return;
            }
            ˊ(context).edit().putString("isOpenChannel", stringExtra).putString("channelInfo", stringExtra2).putBoolean("cotaOk", true).commit();
            Logger.ˎ("OOBE", "save cota, isOpenChannel=" + stringExtra + ", channelInfo=" + stringExtra2);
        }
    }

    public static String ˏ() {
        String str = "";
        if (VERSION.SDK_INT > 25) {
            str = ˋ(0);
            if (TextUtils.isEmpty(str)) {
                str = ˋ(1);
            }
        }
        Logger.ˎ("OOBE", "getVNKey=" + str);
        return str;
    }

    private static String ˋ(int i) {
        String str = "";
        try {
            Class cls = Class.forName("com.huawei.cust.HwCfgFilePolicy");
            return (String) cls.getMethod("getOpKey", new Class[]{Integer.TYPE}).invoke(cls.newInstance(), new Object[]{Integer.valueOf(i)});
        } catch (Exception e) {
            Logger.e("OOBE", "getOpKey Exception: " + e.toString());
            return str;
        }
    }

    public static void ˏ(String str, LinkedHashMap<String, String> linkedHashMap) {
        dla.ˎ(str, linkedHashMap);
    }

    public static LinkedHashMap<String, String> ʽ(Context context) {
        LinkedHashMap<String, String> linkedHashMap = new LinkedHashMap();
        Object obj = "NULL";
        boolean ᐝ = ᐝ(context);
        if (!ᐝ) {
            obj = ˏ();
        }
        Object ʼ = ʼ(context);
        if (ʼ.isEmpty()) {
            ʼ = "NULL";
        }
        linkedHashMap.put("channelInfo", ʼ);
        linkedHashMap.put(HwPayConstant.KEY_COUNTRY, dld.ˎ().ॱˋ());
        linkedHashMap.put("locale", doi.ॱ());
        linkedHashMap.put(HwAccountConstants.EXTRA_OPLOG_PLMN, obj);
        linkedHashMap.put("isOpenMarket", String.valueOf(ᐝ));
        linkedHashMap.put("emuiApiLevel", String.valueOf(ॱ()));
        linkedHashMap.put("buildNumber", ˎ());
        return linkedHashMap;
    }

    public static boolean ᐝ(Context context) {
        return "1".equals(ˊ(context).getString("isOpenChannel", "1"));
    }

    public static String ʼ(Context context) {
        return ˊ(context).getString("channelInfo", "");
    }

    public static int ॱˊ(Context context) {
        return ˊ(context).getInt("changeID", -1);
    }

    public static int ॱ() {
        return azc.ˎ().ॱ();
    }

    public static String ˎ() {
        String ˊ = epw.ˊ("hwouc.hwpatch.version", "");
        String ˊ2 = epw.ˊ("ro.build.product.real.id", "");
        String ˊ3 = epw.ˊ("ro.huawei.build.display.id", "");
        String ˊ4 = epw.ˊ("ro.build.display.id", "");
        if (!dof.ˋ(ˊ)) {
            return ˊ;
        }
        if (!dof.ˋ(ˊ2)) {
            return ˊ2;
        }
        if (!dof.ˋ(ˊ3)) {
            return ˊ3;
        }
        if (dof.ˋ(ˊ4)) {
            return "";
        }
        return ˊ4;
    }

    public static int ˋॱ(Context context) {
        return ˊ(context).getInt("maxDisplay", 18);
    }

    public static boolean ˏॱ(Context context) {
        return ˊ(context).getBoolean("cotaOk", false);
    }

    public static void ˊ() {
        if (!eqp.ʼ() && !diu.ˊ().ˎ()) {
            dla.ˎ();
        }
    }

    public static void ͺ(Context context) {
        cei.ˋ(context, "OOBE", 2018012701);
    }

    public static boolean ˊॱ(Context context) {
        if (VERSION.SDK_INT > 25) {
            NotificationManager notificationManager = (NotificationManager) context.getSystemService("notification");
            if (notificationManager != null) {
                for (StatusBarNotification id : notificationManager.getActiveNotifications()) {
                    if (id.getId() == 2018012701) {
                        return true;
                    }
                }
            }
        }
        return false;
    }

    public static boolean ॱˋ(Context context) {
        TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService("phone");
        if (telephonyManager == null) {
            return false;
        }
        if (telephonyManager.getSimState() == 5) {
            return true;
        }
        return false;
    }

    public static boolean ˋ() {
        boolean z = false;
        if (ॱ() >= 21) {
            z = true;
        }
        if (dlh.ˊ().ˋ() && dlh.ˊ().ˏ()) {
            return dlh.ˊ().ॱ();
        }
        return z;
    }

    @RequiresApi(api = 26)
    public static String ᐝ() {
        String str = "";
        if (ContentManager.getInstant().getContext().checkSelfPermission("android.permission.READ_PHONE_STATE") == 0) {
            return Build.getSerial();
        }
        Logger.e("OOBE", "no permission when getSN");
        return str;
    }

    public static String ʽ() {
        return epw.ˊ("ro.hw.vendor", "");
    }

    public static String ॱॱ() {
        return epw.ˊ("ro.hw.country", "");
    }

    public static boolean ˎ(Context context, String str) {
        if (str == null) {
            return false;
        }
        PackageInfo packageInfo;
        try {
            packageInfo = context.getPackageManager().getPackageInfo(str, 0);
        } catch (NameNotFoundException e) {
            packageInfo = null;
            Logger.e("OOBE", "app is not installed:" + str);
        }
        if (packageInfo != null) {
            return true;
        }
        return false;
    }
}
